<?php
/*
* @Date: 2021-01-28 17:14:59
* @名称: 后台 · 漫画 · 获取 · 获取漫画列表
* @版本: 0.01
* @作者: 初雪桜
* @邮箱: 202184199@qq.com
* @最后编辑: 初雪桜
 * @LastEditTime: 2021-01-28 23:41:26
 * @FilePath: /Site/app/useradmin/controller/Comics/Get/Method/ComicsList.php
*/

namespace app\useradmin\controller\Comics\Get;


use app\BaseController;
use think\facade\Db;

class ComicsList extends BaseController
{
    /**
     * @方法名: 获取漫画列表
     * @作者: 初雪桜
     * @信息: 获取漫画列表 一个网页
     * @param Int $page
     * @param Int $seleNumber
     * @param Json $user_info
     * @return Html
     */
    public function GetComicsList($page, $seleNumber, $user_info)
    {

        //!首先定位到协作/创作者表
        $data_list =  Db::table('author_and_chinese_team')
            ->where([
                "author_and_chinese_team.user_id" => $user_info['_id'] //@a 查询 我所属于的漫画
            ])
            ->alias('author_and_chinese_team')
            ->join("book_list book_list", "book_list._id = author_and_chinese_team.book_id")
            ->limit($page * $seleNumber - $seleNumber, $seleNumber)
            ->join('user_info user_info', 'user_info._id = book_list.user_id')
            ->Join('book_info book_info', 'book_list._id = book_info._id')
            ->order('book_list.id desc')
            ->field([
                "book_list.id", //在数据库id
                "book_list.title", //标题
                "book_list._id", //漫画id
                "book_info.categories", //分类
                "book_info.tags", //分类
                "book_list.created_at", //创建时间
                "book_list.file_server", //服务器地址
                "book_list.path", //路径
                "user_info.name as author", //作者姓名
            ])
            ->select();
        $data_list_count = Db::table('book_list')
            ->where([
                "state" => 1,
                "delete" => 0, //没有被删除的
            ])
            ->count();
        return view(
            'Comics/ComicsList/ComicsList',
            [
                "comicsList" => $data_list,
                "ComicsListCount" => "$data_list_count",
                "page" => $page,
                'springboard' => config("globalsettings.PictureSpringboard"),
                "url" => 'http://' . $_SERVER['HTTP_HOST'] . "/",
            ]
        );
    }
}
